<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户名存在验证</title>
    <script src="js/jquery.js"></script>
    <script>
        $(function (){
            $("#username").blur(function () {
                var username=$(this).val();
                var spans=$("#spans");
                $.post("jsonTestTwo",{"username":username},function (data) {
                    if(data.user_exist)
                    {
                        spans.css("color","red");
                        spans.html(data.msg);
                    }
                    else
                    {
                        spans.css("color","blue");
                        spans.html(data.msg);
                    }
                })
            })
        });
    </script>
</head>
<body>
<form>
    <input type="text" name="username" id="username" placeholder="请输入用户名">
    <span id="spans"></span>
    <br>
    <input type="text" name="password" id="password" placeholder="请输入密码">
    <br>
    <input type="submit" value="注册">
</form>
</body>
</html>